<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<c:set var="base" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>文章列表</title>
</head>
<body>
<div class="row">
    <div class="col-lg-10"><h3><a href="${base}/article?method=create">创建</a></h3></div>
</div>
<div class="row">
    <c:forEach items="${page.content}" var="article">
        <div class="col-lg-10">
            <h2>${article.name}</h2>

            <p class="text-danger">
                <fmt:formatDate value="${article.lastEditTime==null?article.createTime: article.lastEditTime}"
                                pattern="yyyy-MM-dd HH:mm:ss"/>
                <a href="${base}/article?method=delete&id=${article.id}">删除</a>
                <a href="${base}/article?method=toUpdate&id=${article.id}">编辑</a>
            </p>

            <p>${article.content}</p>

            <p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
        </div>
    </c:forEach>
    <nav>
        <ul class="pagination">
            <li>
                <a href="article?method=list&pageNumber=${page.number-1}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <li>
                <span aria-hidden="true">当前页：${page.number} &nbsp; &nbsp;总页数： ${page.totalPages} </span>
            </li>
            <li>
                <a href="article?method=list&pageNumber=${page.number+1}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        </ul>
    </nav>
</div>
</body>
</html>
